-
Notifications
You must be signed in to change notification settings - Fork 122
Add a list of potentially applicable extensions to every class page #2053
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
lib/src/model.dart
Outdated
Iterable<Extension> get potentiallyApplicableExtensions { | ||
if (_potentiallyApplicableExtensions == null) { | ||
if (name.contains('BaseTest')) { | ||
print('hello'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you want to keep this debug code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, oops, will delete.
lib/src/model.dart
Outdated
@@ -1326,6 +1350,28 @@ class Extension extends Container | |||
ElementType.from(_extension.extendedType, library, packageGraph); | |||
} | |||
|
|||
/// Returns [true] if this extension could be applicable to any possible | |||
/// instantiation of [c]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not sound mathematically rigorous :-)
Maybe "...if there is an instantiation of [c] to which this extension could be applied".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, better. Done.
} | ||
return a; | ||
}).toList(), | ||
nullabilitySuffix: classInstantiated.nullabilitySuffix); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's be explicit, use NullabilitySuffix.none
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer to preserve whatever I was given rather than explicitly specify something potentially wrong.
The beginnings of a fix for @munificent's #2021. We do not currently display methods that are applicable (that will need to come in a followup), but can calculate which extensions at a top level are likely, via the type system, to have methods that can be applied.
There are problems with this PR including inefficient lookups in the case where many extensions are defined and reaching into private analyzer interfaces, both of which will need to be fixed in followups.